﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ZPod.MTG.Windows
{
	public partial class CardDetailDialog : Form
	{
		#region Private Properties

		private Card _card;

		#endregion

		#region Public Properties

		public Card Card
		{
			get
			{
				return _card;
			}
			set
			{
				lock (cardPicture)
				{
					_card = value;
					this.Text = value.Name;
					attachedCardsPanel.Clear();
					attachedCardsPanel.AddCards(value.AttachedCards);
					if (cardPicture.Image != null)
					{
						cardPicture.Image.Dispose();
						cardPicture.Image = null;
					}
					cardPicture.ImageLocation = CardStorage.GetCardPicture(value);
				}
			}

		}

		#endregion

		#region Public Constructors

		public CardDetailDialog(Card card)
		{
			InitializeComponent();

			Card = card;
			cardPicture.WaitOnLoad = true;
		}

		#endregion

		#region Public Methods

		public void RefreshCards()
		{
			attachedCardsPanel.RefreshCards();
		}

		public void AddContextualOption(string title, CardPanel.CardEvent handler)
		{
			attachedCardsPanel.ContextualOptions.Add(title, handler);
		}

		#endregion

		#region Private Methods

		private void CardDetailDialog_Resize(object sender, EventArgs e)
		{
			attachedCardsPanel.RefreshCards();
		}

		#endregion
	}
}
